package com.minimoment.model.service.impl;

import com.minimoment.base.BaseSupportImpl;
import com.minimoment.model.domain.Screenings;
import com.minimoment.model.service.ScreeningsService;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by etund on 2014/11/8.
 */
@Transactional
@Service
@SuppressWarnings("all")
public class ScreeningsServiceImpl extends BaseSupportImpl<Screenings> implements ScreeningsService {
    /**
     * 查询当前影院当天有多少播放的影片
     */
    public List<Screenings> getCurrentByTheaterId(Long theaterId){
        list = this.getSession().createCriteria(Screenings.class)
                .createAlias("theater","t")
                .add(Restrictions.eq("t.id",theaterId)).list();
        return this.list;
    }

    @Override
    public List<Screenings> getByTMId(Long movieId, Long theaterId) {
        list = this.getSession().createQuery("from Screenings s where s.movie.id = ? and s.theater.id=?")
                .setParameter(0,movieId)
                .setParameter(1,theaterId).list();
        return list;
    }
}
